import 'package:get/get.dart';

class CartoonAppBarController extends GetxController {
  var imageUrls = <String>[];
  final List<double> xPositions = List.filled(3, 0);
  final List<double> yPositions = List.filled(3, 40);
  final List<double> scales = List.filled(3, 0.01);
  double inputViewWidth = Get.width - 30;
  var isReset = false;

  void initialize(List<String> urls) {
    imageUrls.clear();
    imageUrls.addAll(urls);
    update();
  }

  Future<void> startAnimationSequence({bool reset = false}) async {
    if (imageUrls.length != 3) {
       return;
    }
    final int delayMultiplier = isReset ? 50 : 30;
    inputViewWidth = isReset ? Get.width - 30 : Get.width - 160;
    update();
    for (int i = 0; i < 3; i++) {
      await Future.delayed(Duration(milliseconds: delayMultiplier * i));
      xPositions[i] = isReset ? 0 : 40;
      yPositions[i] = isReset ? 40 : 0;
      scales[i] = isReset ? 0.01 : 1.0;
      update();
    }
    isReset = reset;
  }
}